home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / ODF Release 3 / Developer University / DU Projects / DataSave / Sources / Frame.cpp < prev    next >
Encoding:
Text File  |  1996-12-11  |  3.0 KB  |  109 lines  |  [TEXT/CWIE]

  1. //    Release Version:    $ ODF 3 $
  2. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  3.  
  4. //=======================================================================
  5. #ifndef PART_H
  6. #include "Part.h"
  7. #endif
  8.  
  9. #ifndef CONTENT_H
  10. #include "Content.h"
  11. #endif
  12.  
  13. #ifndef FRAME_H
  14. #include "Frame.h"
  15. #endif
  16.  
  17. #ifndef COMMANDS_H
  18. #include "Commands.h"            // CPizzaCommand
  19. #endif
  20.  
  21. #ifndef DEFINES_K
  22. #include "Defines.k"            // command numbers
  23. #endif
  24.  
  25. // ----- Framework Layer -----
  26. #ifndef FWCONTXT_H
  27. #include "FWContxt.h"            // FW_CViewContext
  28. #endif
  29.  
  30. #ifndef FWEVENT_H
  31. #include "FWEvent.h"            // FW_CMenuEvent, FW_CMouseEvent
  32. #endif
  33.  
  34. #ifndef FWEVENTU_H
  35. #include "FWEventU.h"            // FW_IsCommandKeyPressed
  36. #endif
  37.  
  38. // ----- OS Layer -----
  39. #ifndef FWODGEOM_H
  40. #include "FWODGeom.h"            // FW_NewODShape
  41. #endif
  42.  
  43. #ifndef FWACQUIR_H
  44. #include "FWAcquir.h"            // FW_CAcquiredODShape
  45. #endif
  46.  
  47. #ifndef FWRECSHP_H
  48. #include "FWRecShp.h"            // FW_CRectShape
  49. #endif
  50.  
  51. //========================================================================================
  52. #ifdef FW_BUILD_MAC
  53. #pragma segment DataSave
  54. #endif
  55.  
  56. FW_DEFINE_AUTO(CDataSaveFrame)
  57.  
  58. //========================================================================================
  59. CDataSaveFrame::CDataSaveFrame(Environment* ev, ODFrame* odFrame, 
  60.                                 FW_CPresentation* presentation, CDataSaveContent* content)
  61.   : FW_CFrame(ev, odFrame, presentation, content->GetPart(ev)),
  62.     fDataSaveContent(content)
  63. {
  64. }
  65.  
  66. //----------------------------------------------------------------------------------------
  67. CDataSaveFrame::~CDataSaveFrame()
  68. {
  69. }
  70.  
  71. //----------------------------------------------------------------------------------------
  72. FW_Handled 
  73. CDataSaveFrame::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
  74. {    
  75.     FW_CPoint where = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
  76.     this->GetContentView(ev)->FrameToViewContent(ev, where);    
  77.     CPizzaCommand* cmd = FW_NEW(CPizzaCommand, (ev, cMakePizzaCmd, this, 
  78.                                                 fDataSaveContent, where) );
  79.     cmd->Execute(ev);
  80.     return FW_kHandled;
  81. }
  82.  
  83. //----------------------------------------------------------------------------------------
  84. void 
  85. CDataSaveFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)    // Override
  86. {
  87.     FW_CViewContext context(ev, this, odFacet, invalidShape);
  88.     FW_CRect invalidRect = FW_GetShapeBoundingBox(ev, invalidShape);
  89.     FW_CRectShape::RenderRect(context, invalidRect, FW_kFill, FW_kRGBLightGray);
  90. //    FW_CRectShape::RenderRect(context, invalidRect, FW_kFill, FW_kWhiteEraseInk);
  91.     
  92.     // draw pizzas
  93.     CPizzaCollection* list = fDataSaveContent->MyGetPizzaList();
  94.     CPizzaCollectionIterator iter(list);
  95.     CPizza* pizza = NULL;
  96.     ODShape* shape = NULL;
  97.     for (pizza = (CPizza*) iter.First(); iter.IsNotComplete(); pizza = (CPizza*) iter.Next()) {
  98.         if (::FW_IsCommandKeyPressed()) {
  99.             FW_CAcquiredODShape rectShape = ::FW_NewODShape(ev, pizza->GetBounds());
  100.             shape = rectShape->Intersect(ev, invalidShape);
  101.             if ( ! shape->IsEmpty(ev) ) 
  102.                 pizza->Draw(context);
  103.             }
  104.         else 
  105.             if (invalidRect.IsIntersecting( pizza->GetBounds() ) )
  106.                 pizza->Draw(context);
  107.         }
  108. }
  109.